package com.itheima.reggie.common;

/**
 * Created with IntelliJ IDEA.
 * User: zjz
 * Date: 2022/07/21 20:22
 * Description:
 * Version: V1.0
 */

/**
 * 基于ThreadLocal封装的工具类,用户保存和获取当前登录用户id
 * 作用范围是一个线程之内
 */
public class BaseContext {

    private static ThreadLocal<Long>  threadLocal= new ThreadLocal<>();

    /**
     * 设置值
     * @param id
     */
    public static void setCurrentId(Long id ){
        threadLocal.set(id);
    }


    /**
     * 获取值
     * @return
     */
    public static Long getCurrentId(){
        return threadLocal.get();
    }

}
